package io.gitee.pkmer.ddd.autoconfig;

import io.gitee.pkmer.ddd.shared.dispatch.CmdDispatcher;
import io.gitee.pkmer.ddd.shared.event.DomainEventBus;
import io.gitee.pkmer.ddd.shared.event.DomainEventBusImpl;
import io.gitee.pkmer.ddd.shared.event.annotations.DDDBus;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

/**
 * @author <a href="mailto:1193094618@qq.com">pkmer</a>
 * <br>
 * At 2024/8/22
 */

@AutoConfiguration
public class DddAutoConfig {

    @Bean
    @DDDBus
    public DomainEventBus defaultDomainEventBus(){
        return new DomainEventBusImpl();
    }

    @Bean
    @ConditionalOnMissingBean(CmdDispatcher.class)
    public CmdDispatcher cmdDispatcher(){
        return new CmdDispatcher();
    }
}
